package com.atguigu.guli.service.edu.controller.api;

import com.atguigu.guli.common.base.result.R;
import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.service.TeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author:何梦峰
 * @DATE: 2021/1/22 9:40
 */
@CrossOrigin //允许跨域
@Api(description = "讲师管理")
@RestController
@RequestMapping("/api/edu/teacher")
@Slf4j
public class TeacherApiController {

    @Autowired
    TeacherService teacherService;

    @ApiOperation(value="所有讲师列表")
    @GetMapping("list")
    public R list(){
        List<Teacher> list = teacherService.list();
        return R.ok().data("item",list).message("获取讲师列表成功");
    }

    @ApiOperation(value="获取讲师信息")
    @GetMapping("get/{id}")
    public R get(String id){
        Map<String,Object> map= teacherService.selectTeacherInfoById(id);
        return R.ok().data("item",map).message("获取讲师列表成功");
    }
}
